package ExceptionDemo1;

public class ExceptionDemo2 {
    public static void main(String[] args) {
        System.out.println("程序开始执行");
        try{
           System.out.println(div(10,0));
           System.out.println("底层执行成功");
        }
        catch(Exception e){
            System.out.println("出现异常");
            e.printStackTrace();
        }
        System.out.println("程序执行结束");
    }
    public static int div(int a, int b) throws Exception {
        if(b==0){
            System.out.println("除数不能为0");
            throw new Exception("除数不能为0");
        }
        int result =a/b;
        return result;
    }
}
